<?php echo $head ?>
<?php echo $b_head?>
<form action="" method="post" class="form form-horizontal">
    <div class="panel panel-info settings" style="display: block;">
        <div class="panel panel-info">
            <div class="panel-heading" style="color:red;">储值设置（建议总数不超过6个，充值金额不能小于0，必须小于20000）</div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">首充双倍</label>
                    <div class="col-sm-9">
                        <label><input type="radio" name="isdouble" checked="checked" value="0"> 关闭</label>
                        <label style="margin-left: 10px;"><input type="radio" name="isdouble" value="1"> 开启</label>
                        <div class="help-block">首充双倍是每个额度的金额都有一次双倍机会</div>
                        <div class="help-block">仅仅当用户充值金额在下列设置的金额中才有效，否则无效</div>
                        <div class="help-block">例如：开启首充双倍。用户第一次充值1元，实际到账2元，用户第一次充值3元，实际到账6元</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">首充双倍提示语</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="font[double_tip]" class="form-control" value="">
                        <div class="help-block">建议十六个字内</div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-sm-12">
                        <table class="table">
                            <thead>
                            <tr>
                                <th style="width:60px;"></th>
                                <th style="width:200px;">金额</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody id="tbody">
                            <tr class="recharge-item">
                                <td><a href="javascript:;" class="btn btn-default btn-sm btn-move"><i
                                            class="fa fa-arrows"></i></a></td>
                                <td><input type="number" class="form-control" name="money[]" value="6"></td>
                                <td>
                                    <button type="button" class="btn btn-danger  btn-sm"
                                            onclick="removeRecharge(this)"><i class="fa fa-remove"></i></button>
                                </td>
                            </tr>
                            <tr class="recharge-item">
                                <td><a href="javascript:;" class="btn btn-default btn-sm btn-move"><i
                                            class="fa fa-arrows"></i></a></td>
                                <td><input type="number" class="form-control" name="money[]" value="18"></td>
                                <td>
                                    <button type="button" class="btn btn-danger  btn-sm"
                                            onclick="removeRecharge(this)"><i class="fa fa-remove"></i></button>
                                </td>
                            </tr>
                            <tr class="recharge-item">
                                <td><a href="javascript:;" class="btn btn-default btn-sm btn-move"><i
                                            class="fa fa-arrows"></i></a></td>
                                <td><input type="number" class="form-control" name="money[]" value="36"></td>
                                <td>
                                    <button type="button" class="btn btn-danger  btn-sm"
                                            onclick="removeRecharge(this)"><i class="fa fa-remove"></i></button>
                                </td>
                            </tr>
                            <tr class="recharge-item">
                                <td><a href="javascript:;" class="btn btn-default btn-sm btn-move"><i
                                            class="fa fa-arrows"></i></a></td>
                                <td><input type="number" class="form-control" name="money[]" value="58"></td>
                                <td>
                                    <button type="button" class="btn btn-danger  btn-sm"
                                            onclick="removeRecharge(this)"><i class="fa fa-remove"></i></button>
                                </td>
                            </tr>
                            <tr class="recharge-item">
                                <td><a href="javascript:;" class="btn btn-default btn-sm btn-move"><i
                                            class="fa fa-arrows"></i></a></td>
                                <td><input type="number" class="form-control" name="money[]" value="72"></td>
                                <td>
                                    <button type="button" class="btn btn-danger  btn-sm"
                                            onclick="removeRecharge(this)"><i class="fa fa-remove"></i></button>
                                </td>
                            </tr>
                            <tr class="recharge-item">
                                <td><a href="javascript:;" class="btn btn-default btn-sm btn-move"><i
                                            class="fa fa-arrows"></i></a></td>
                                <td><input type="number" class="form-control" name="money[]" value="156"></td>
                                <td>
                                    <button type="button" class="btn btn-danger  btn-sm"
                                            onclick="removeRecharge(this)"><i class="fa fa-remove"></i></button>
                                </td>
                            </tr>
                            </tbody>
                            <tbody>
                            <tr>
                                <td colspan="4">
                                    <button type="button" class="btn btn-default  btn-sm" onclick="addRecharge()"><i
                                            class="fa fa-plus"></i> 添加金额
                                    </button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <button class="btn btn-primary" type="submit" name="submit" value="提交">提交</button>
</form>
</div>
<script>
    function removeRecharge(obj) {
        $(obj).closest('.recharge-item').remove();
    }
    function addRecharge() {
        var html = '<tr class="recharge-item">';
        html += '<td><a href="javascript:;" class="btn btn-default btn-sm btn-move"><i class="fa fa-arrows"></i></a></td>';
        html += '<td><input type="number" class="form-control" name="money[]" /></td>';
        html += '<td><button type="button" class="btn btn-danger  btn-sm" onclick="removeRecharge(this)"><i class="fa fa-remove"></i></button>';
        html += '</td>';
        html += '</tr>';
        $('#tbody').append(html);
        bindEvents();
    }
    function bindEvents() {
        require(['jquery', 'util'], function ($, util) {
            $('.btn-select-pic').unbind('click').click(function () {
                var imgitem = $(this).closest('.img-item');
                util.image('', function (data) {
                    imgitem.find('img').attr('src', data['url']);
                    imgitem.find('input').val(data['attachment']);
                });
            });
        });
        require(['jquery.ui'], function () {
            $("#tbody").sortable({handle: '.btn-move'});
        });
    }
    $(function () {
        bindEvents();
    });
</script>
